#!/usr/bin/env python
#-*-encoding:utf-8-*-
'''
Created on 2015年7月28日

@author: chenyongbing
'''
import sys,os,datetime
#current_dir = os.path.dirname(__file__)
current_dir = os.path.split(os.path.realpath(__file__))[0]

sys.path.append(os.path.join(current_dir,'../'))
from base.retail_datas import myRetailDatas
from base.file_method import *
raw_group_path = '/Udisk/rawdata_group/'

def get_raw_line(groups=[],day=None):
    shop_groups = myRetailDatas.get_shop_groups_by_group(groups)
    if day==None:
        day = datetime.date.today().strftime('%Y-%m-%d')
    
    for shop_group in shop_groups:
        raw_file = raw_group_path+'/'+day+'/'+str(shop_group)+'.txt.tar.gz' 
        print raw_file
        if not os.path.exists(raw_file):continue
        output = openTarFile(raw_file)
        print shop_group,len(output.split('\n'))
    

if __name__ == '__main__':
    import argparse
    parser = argparse.ArgumentParser(description='args')
    parser.add_argument('--groups', metavar=u'groups ', required=True)
    parser.add_argument('--day', metavar=u'day', default=None)
    args = parser.parse_args()
    
    groups  = args.groups
    day = args.day
    
    